<%@page	import="model.*" 
	import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>INTI3E Prototype</title>
		<link rel="stylesheet" href="layout.css" type="text/css" />
		<jsp:include page="initialize.jsp"  flush="true" />  
	</head>
	<body>
		<jsp:include page="menu.jsp"  flush="true" />
		&nbsp;
		<div id="wrapper">
			<% 	
				session = request.getSession();
				ArrayList<Log> logs = (ArrayList<Log>)request.getAttribute("logs");
				ArrayList<Page> pages = (ArrayList<Page>)request.getAttribute("pages");
				Collections.sort(logs);
			%>
			<div style="padding-top:20px">
				<a href="LogServlet?page=top10p" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-circle-arrow-e"></span>Top 10 bezochte pagina's</a>
				<a href="LogServlet?page=top10i" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-circle-arrow-e"></span>Sorteer op IP adres</a>
				<a href="LogServlet?page=top10d" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-circle-arrow-e"></span>Hoeveelheid pagina's bezocht</a>
				<a href="LogServlet?page=top10u" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-circle-arrow-e"></span>Sorteer per gebruiker</a>
			</div>
		
			<table border="1" bordercolor="DDD9DE" cellpadding="10">
				<tr>
					<%
					boolean userBoolean = false , dateBoolean = false , pathBoolean = false , ipBoolean = false, countBoolean = false;
					for(Log log : logs){
						if(log.getUser() != null && userBoolean == false){
							userBoolean = true;
			 	       		out.println("<th scope=" + "col" + ">User</th>");
						}
						if(log.getDate() != null && dateBoolean == false){
							dateBoolean = true;
			 	       		out.println("<th scope=" + "col" + ">Date</th>");
						}
						if(log.getPath() != null && pathBoolean == false){
							pathBoolean = true;
			 	       		out.println("<th scope=" + "col" + ">Path</th>");
						}
						if(log.getIPaddress() != null && ipBoolean == false){
							ipBoolean = true;
			 	       		out.println("<th scope=" + "col" + ">IP Adress</th>");
						}
						if(log.getCount() != 0 && countBoolean == false){
							countBoolean = true;
			 	       		out.println("<th scope=" + "col" + ">Count</th>");
						}
					}
					%>
				</tr>
				<%
				for(Log log : logs){
					out.println("<tr align="+"middle"+">");
					if(log.getUser() != null){
						out.println("<td>" + log.getUser()+"</td>");
					}
					if(log.getDate() != null){
						out.println("<td>" + log.getDate()+"</td>");
					}
					if(log.getPath() != null){
						out.println("<td>" + log.getPath()+"</td>");
					}
					if(log.getIPaddress() != null){
						if(log.getIPaddress().equals("0:0:0:0:0:0:0:1") || log.getIPaddress().equals("0:0:0:0:0:0:0:1%0")){
			 				out.println("<td>" + "localhost" +"</td>");
						}else{
							out.println("<td>" + log.getIPaddress() +"</td>");
						}
					}
					if(log.getCount() != 0){
						out.println("<td>" + log.getCount() +"</td>");
					}
					out.println("</tr>");
				}
				%>
			</table>
		</div>	
	</html>
		<jsp:include page="footer.jsp"  flush="true" />
	</body>
</html>
	